﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using CollegeShop.Infrastructure.Entities.Entity;
using CollegeShop.Infrastructure.Entities.Enum;

namespace CollegeShop.Infrastructure.Entities.Repository
{
    public class Resource : IAccessible<T_Resource, Resource>, ILogicEntity<T_Resource, Resource>
    {
        public int ID { get; set; }
        public string Path { get; set; }
        public ResourceClient Client { get; set; }


        protected override void Covariant(T_Resource model)
        {
            if (model != null)
            {
                this.ID = model.ID;
                this.Path = model.Path;
                this.Client = (ResourceClient)model.Client;
            }
        }

        protected override T_Resource Inverter(Resource model)
        {
            if (model != null)
            {
                return new T_Resource()
                {
                    Client = (int)model.Client,
                    ID = model.ID,
                    Path = model.Path
                };
            }
            return null;
        }

        public Resource Set(T_Resource dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
